#include<bits/stdc++.h>
using namespace std;
int stones[310] = {0};
bool cmp (const int &a,const int &b){
    return a > b;
}
int main(void){
    int n;
    cin >> n;
    long sum = 0;
    for(int i = 0; i<n; i++){
        scanf("%d",&stones[i]);
    }
    sort(stones,stones+n,cmp);
    int left = 0;
    int right = n - 1;
    sum += stones[0] * stones[0];
    while(left < right){
        sum += (stones[left] - stones[right]) * (stones[left] - stones[right]);
        left ++;
        sum += (stones[left] - stones[right]) * (stones[left] - stones[right]);
        right --;
    }
    cout<<sum;
    return 0;
}